﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
<<<<<<< HEAD

namespace homework1
=======
using System.Collections;

namespace homework2
>>>>>>> a11dbbb (homework2)
{
    internal class Program
    {
        static void Main(string[] args)
        {
<<<<<<< HEAD
            string s1 = "";
            string s2 = "";
            Console.Write("请输入第一个操作数：");
            s1 = Console.ReadLine();
            Console.Write("请输入第二个操作数：");
            s2 = Console.ReadLine();
            char opcode;
            Console.Write("请输入操作符:");
            opcode = Console.ReadKey().KeyChar;
            Console.WriteLine();
            int op1, op2;
            int.TryParse(s1, out op1);
            int.TryParse(s2, out op2);
            int result = 0;

            switch (opcode)
            {
                case '+':
                    result = op1 + op2;
                    Console.WriteLine("计算结果为：" + result);
                    break;
                case '-':
                    result = op1 - op2;
                    Console.WriteLine("计算结果为：" + result);
                    break;
                case '*':
                    result = op1 * op2;
                    Console.WriteLine("计算结果为：" + result);
                    break;
                case '/':
                    result = op1 / op2;
                    Console.WriteLine("计算结果为：" + result);
                    break;
                case '%':
                    result = op1 % op2;
                    Console.WriteLine("计算结果为：" + result);
                    break;
                default:
                    Console.WriteLine("你输入了非法字符,无法计算");
                    break;
            }

            //Console.WriteLine(result);
            //Console.ReadLine();
            Console.WriteLine("按任意键继续...");
            Console.ReadKey();///
        }
    }
}
=======
            //string s = "";
            Console.Write("请输入一个数字:");
            int number = int.Parse(Console.ReadLine());
            findnumber(number);
            Console.WriteLine("请按任意键继续.......");
            Console.ReadKey();
        }
        static void findnumber(int n)
        {
            Queue qu = new Queue();
            Console.WriteLine("该数字的所有素因数为：");
            for(int i=2;i<=n;i++)
            {
                while(n%i==0)
                {
                    if(qu.Count == 0)
                    {
                        qu.Enqueue(i);
                    }
                    else  if((int)qu.Peek()!=i)
                    {
                        int result = (int)qu.Dequeue();
                        Console.Write(result);
                        Console.Write(",");
                        qu.Enqueue(i);
                    }
                    //if (n == i) break;
                    n = n / i;
                }
            }
            while(qu.Count!=0)
            {
                int result = (int)qu.Dequeue();
                Console.Write(result);
                if (qu.Count != 0)
                { 
                    Console.Write(","); 
                }
            }
            Console.WriteLine();
        }
    }
}
>>>>>>> a11dbbb (homework2)
